home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume17 / parseargs / patch01 < prev    next >
Encoding:
Internet Message Format  |  1991-03-18  |  15.0 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i058:  parseargs - functions to parse command line arguments, Patch01
  4. Message-ID: <1991Mar18.160143.2674@sparky.IMD.Sterling.COM>
  5. Date: 18 Mar 91 16:01:43 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: dab18720 eb19e21b 45a61804 df221476
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 17, Issue 58
  11. Archive-name: parseargs/patch01
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. This is a patch for parseargs. The only things that was wrong is that I
  15. incorrectly documented something, (this is NOT a bugfix).
  16.  
  17. This patch consists of two files:
  18.  
  19.     PATCH : patches for 'xparse.c' and 'doc/env_parse.inc'
  20.     TXTPATCH : patches for 'parseargs1.txt' and 'parseargs3.txt'
  21.  
  22. The second file is ONLY needed by those who do not have nroff or troff
  23. available to them.
  24. -- 
  25. ______________________ "And miles to go before I sleep." ______________________
  26.  Brad Appleton                         Harris Corp., Computer Systems Division
  27.    Software Engineer                   2101 West Cypress Creek Road,  M/S 161 
  28.      brad@ssd.csd.harris.com           Fort Lauderdale, FL  33309-1892  USA
  29.        ...!uunet!hcx1!brad                 Phone: (305) 973-5360
  30. ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
  31.  
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of shell archive."
  39. # Contents:  PATCH TXTPATCH
  40. # Wrapped by brad@hcx2 on Mon Mar 18 09:33:10 1991
  41. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  42. if test -f 'PATCH' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'PATCH'\"
  44. else
  45. echo shar: Extracting \"'PATCH'\" \(2415 characters\)
  46. sed "s/^X//" >'PATCH' <<'END_OF_FILE'
  47. X*** doc/env_parse.inc.OLD    Mon Mar 18 09:10:32 1991
  48. X--- doc/env_parse.inc    Sat Mar 16 15:19:28 1991
  49. X***************
  50. X*** 62,66 ****
  51. X  undefined, then parsing behavior set by the programmer is used.
  52. X  If the programmer has not explicitly used
  53. X  .IR parsecntl (3)
  54. X! to modify the parsing behavior will be ``!Prompt + !Ignore'' for Unix
  55. X! MS-DOS, OS/2, and AmigaDOS systems, and ``Prompt'' for VMS systems.
  56. X--- 62,68 ----
  57. X  undefined, then parsing behavior set by the programmer is used.
  58. X  If the programmer has not explicitly used
  59. X  .IR parsecntl (3)
  60. X! to modify the parsing behavior, then the default behavior will be
  61. X! ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for AmigaDOS
  62. X! systems, ``CaseIgnore'' for MS-DOS and OS/2 systems, and ``Prompt''
  63. X! for VMS systems.
  64. X*** xparse.c.OLD    Mon Mar 18 09:10:36 1991
  65. X--- xparse.c    Mon Mar 18 08:51:08 1991
  66. X***************
  67. X*** 537,543 ****
  68. X--- 537,553 ----
  69. X     else  anchor = ad;
  70. X  
  71. X       /* set default parse-flags */
  72. X+ #ifndef ibm_style
  73. X     cmd_flags(argd) = pa_DEFAULTS;
  74. X+ #else
  75. X+    {
  76. X+       char *pfx = getenv( "SWITCHAR" );
  77. X+       if ( pfx  &&  *pfx == '-' )
  78. X+          cmd_flags(argd) = pa_FLAGS1ST;
  79. X+       else
  80. X+          cmd_flags(argd) = pa_DEFAULTS;
  81. X+    }
  82. X+ #endif
  83. X  
  84. X       /* if new-style, get the purpose from the command name */
  85. X     if ( !old_style  &&  cmd_name(argd) ) {
  86. X***************
  87. X*** 1168,1176 ****
  88. X  **
  89. X  **    If the environment variable "PARSECNTL" is empty or undefined, then
  90. X  **    parsing behavior set by the programmer is used.  If the programmer has
  91. X! **    not explicitly used parsecntl(3) to modify the parsing behavior will
  92. X! **    be "!Prompt + !Ignore" for Unix and AmigaDOS systems, "Prompt" for
  93. X! **    VMS systems, and "CaseIgnore" for MS-DOS and OS/2 systems.
  94. X  **
  95. X  ** ^REQUIREMENTS:
  96. X  **    <cmd> must point to an array that has been declared using the CMD_XXXX
  97. X--- 1178,1187 ----
  98. X  **
  99. X  **    If the environment variable "PARSECNTL" is empty or undefined, then
  100. X  **    parsing behavior set by the programmer is used.  If the programmer has
  101. X! **    not explicitly used parsecntl(3) to modify the parsing behavior, then
  102. X! **    the default behavior will be "Flags1st" for Unix Systems,
  103. X! **    "!Prompt + !Ignore" for AmigaDOS systems, "Prompt" for VMS systems,
  104. X! **    and "CaseIgnore" for MS-DOS and OS/2 systems.
  105. X  **
  106. X  ** ^REQUIREMENTS:
  107. X  **    <cmd> must point to an array that has been declared using the CMD_XXXX
  108. END_OF_FILE
  109. if test 2415 -ne `wc -c <'PATCH'`; then
  110.     echo shar: \"'PATCH'\" unpacked with wrong size!
  111. fi
  112. # end of 'PATCH'
  113. fi
  114. if test -f 'TXTPATCH' -a "${1}" != "-c" ; then 
  115.   echo shar: Will not clobber existing file \"'TXTPATCH'\"
  116. else
  117. echo shar: Extracting \"'TXTPATCH'\" \(9637 characters\)
  118. sed "s/^X//" >'TXTPATCH' <<'END_OF_FILE'
  119. XNo differences encountered
  120. X*** parseargs1.txt.OLD    Mon Mar 18 09:24:28 1991
  121. X--- parseargs1.txt    Mon Mar 18 09:25:29 1991
  122. X***************
  123. X*** 607,615 ****
  124. X       If    the environment    variable ``PARSECNTL'' is empty    or
  125. X       undefined,    then parsing behavior set by the programmer is
  126. X       used.  If the programmer has not explicitly used
  127. X!      parsecntl(3) to modify the    parsing    behavior will be
  128. X!      ``!Prompt + !Ignore'' for Unix MS-DOS, OS/2, and AmigaDOS
  129. X!      systems, and ``Prompt'' for VMS systems.
  130. X  
  131. X  USAGE MESSAGES
  132. X       Through the use of    an environment variable    (or a VMS
  133. X--- 607,616 ----
  134. X       If    the environment    variable ``PARSECNTL'' is empty    or
  135. X       undefined,    then parsing behavior set by the programmer is
  136. X       used.  If the programmer has not explicitly used
  137. X!      parsecntl(3) to modify the    parsing    behavior, then the
  138. X!      default behavior will be ``Flags1st'' for Unix systems,
  139. X!      ``!Prompt + !Ignore'' for AmigaDOS    systems, ``CaseIgnore''
  140. X!      for MS-DOS    and OS/2 systems, and ``Prompt'' for VMS systems.
  141. X  
  142. X  USAGE MESSAGES
  143. X       Through the use of    an environment variable    (or a VMS
  144. X***************
  145. X*** 650,656 ****
  146. X       Description
  147. X        The command description is printed.
  148. X  
  149. X-      Terse
  150. X  
  151. X  
  152. X  
  153. X--- 651,656 ----
  154. X***************
  155. X*** 665,670 ****
  156. X--- 665,671 ----
  157. X  
  158. X  
  159. X  
  160. X+      Terse
  161. X        Terse    mode, just print command-line synopsis.
  162. X  
  163. X       Verbose
  164. X***************
  165. X*** 716,722 ****
  166. X              FALSE (an empty string).
  167. X  
  168. X        -X        A Boolean ``X Rated'' flag.     This is not
  169. X-             printed in the usage message.
  170. X  
  171. X  
  172. X  
  173. X--- 717,722 ----
  174. X***************
  175. X*** 731,736 ****
  176. X--- 731,738 ----
  177. X  
  178. X  
  179. X  
  180. X+             printed in the usage message.
  181. X+ 
  182. X       The two positional    arguments are both strings, as is the
  183. X       final list.  If we    were to    invoke the above script    with the
  184. X       following command line:
  185. X***************
  186. X*** 781,788 ****
  187. X  
  188. X       ##    parse command-line and save assignments    in a temporary file ##
  189. X       parseargs -s sh -e    ARGUMENTS -u --    "$NAME"    "$@" >/tmp/tmp$$
  190. X-      if    [ $? -ne 0 ]
  191. X-        then rm -f /tmp/tmp$$; exit 2  ## non-zero status (usage    given)
  192. X  
  193. X  
  194. X  
  195. X--- 783,788 ----
  196. X***************
  197. X*** 797,802 ****
  198. X--- 797,804 ----
  199. X  
  200. X  
  201. X  
  202. X+      if    [ $? -ne 0 ]
  203. X+        then rm -f /tmp/tmp$$; exit 2  ## non-zero status (usage    given)
  204. X       fi
  205. X  
  206. X       ##    evaluate results from parseargs    and remove temporary file
  207. X***************
  208. X*** 846,857 ****
  209. X       4      A syntax error was encountered in the    argument
  210. X        specification    string that was    specified to parseargs.
  211. X  
  212. X- FILES
  213. X-      /usr/local/parseargs.pl
  214. X-       This file defines a perl function named parseargs to
  215. X  
  216. X  
  217. X  
  218. X  Page 13
  219. X  
  220. X  
  221. X--- 848,857 ----
  222. X       4      A syntax error was encountered in the    argument
  223. X        specification    string that was    specified to parseargs.
  224. X  
  225. X  
  226. X  
  227. X  
  228. X+ 
  229. X  Page 13
  230. X  
  231. X  
  232. X***************
  233. X*** 863,868 ****
  234. X--- 863,871 ----
  235. X  
  236. X  
  237. X  
  238. X+ FILES
  239. X+      /usr/local/parseargs.pl
  240. X+       This file defines a perl function named parseargs to
  241. X        parse    arguments more conveniently for    perl-scripts. The
  242. X        function is both documented and implemented in this
  243. X        file.    The user should    ``require'' this file in his/her
  244. X***************
  245. X*** 913,923 ****
  246. X       Hence multiple ``leading dash'' arguments may specified as
  247. X       follows:
  248. X  
  249. X-       -f-dash_arg1 -f-dash_arg2  ...
  250. X  
  251. X  
  252. X- 
  253. X- 
  254. X  Page 14
  255. X  
  256. X  
  257. X--- 916,923 ----
  258. X***************
  259. X*** 929,934 ****
  260. X--- 929,936 ----
  261. X  
  262. X  
  263. X  
  264. X+       -f-dash_arg1 -f-dash_arg2  ...
  265. X+ 
  266. X  BUGS
  267. X       It    does not make sense to use any arguments of type argTBool
  268. X       since parseargs currently has no way of knowing what the
  269. X***************
  270. X*** 971,978 ****
  271. X  AUTHOR
  272. X       Brad Appleton  (brad@ssd.csd.harris.com)
  273. X       Harris Computer Systems, Fort Lauderdale, FL USA
  274. X- 
  275. X- 
  276. X  
  277. X  
  278. X  
  279. X--- 973,978 ----
  280. X*** parseargs3.txt.OLD    Mon Mar 18 09:24:29 1991
  281. X--- parseargs3.txt    Mon Mar 18 09:25:47 1991
  282. X***************
  283. X*** 643,656 ****
  284. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  285. X       fined, then parsing behavior set by the programmer    is used.
  286. X       If    the programmer has not explicitly used parsecntl(3) to
  287. X!      modify the    parsing    behavior will be ``!Prompt + !Ignore''
  288. X!      for Unix MS-DOS, OS/2, and    AmigaDOS systems, and ``Prompt''
  289. X!      for VMS systems.
  290. X  
  291. X  USAGE MESSAGES
  292. X       Through the use of    an environment variable    (or a VMS sym-
  293. X       bol), the user may    control    the syntax and the verbosity of
  294. X-      the command-usage messages    that are printed by parseargs.
  295. X  
  296. X  
  297. X  
  298. X--- 643,656 ----
  299. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  300. X       fined, then parsing behavior set by the programmer    is used.
  301. X       If    the programmer has not explicitly used parsecntl(3) to
  302. X!      modify the    parsing    behavior, then the default behavior will
  303. X!      be    ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for
  304. X!      AmigaDOS systems, ``CaseIgnore'' for MS-DOS and OS/2 sys-
  305. X!      tems, and ``Prompt'' for VMS systems.
  306. X  
  307. X  USAGE MESSAGES
  308. X       Through the use of    an environment variable    (or a VMS sym-
  309. X       bol), the user may    control    the syntax and the verbosity of
  310. X  
  311. X  
  312. X  
  313. X***************
  314. X*** 665,670 ****
  315. X--- 665,671 ----
  316. X  
  317. X  
  318. X  
  319. X+      the command-usage messages    that are printed by parseargs.
  320. X       The desired level of verbosity may    be set by defining the
  321. X       environment variable ``USAGECNTL" to be a combination of
  322. X       strings (case insensitive). The value of each string con-
  323. X***************
  324. X*** 715,725 ****
  325. X        Same as LongOpts.
  326. X  
  327. X  
  328. X-      If    the environment    variable ``USAGECNTL'' is empty    or unde-
  329. X-      fined, then the default usage level (which    is presently
  330. X  
  331. X  
  332. X  
  333. X  Page 11
  334. X  
  335. X  
  336. X--- 716,725 ----
  337. X        Same as LongOpts.
  338. X  
  339. X  
  340. X  
  341. X  
  342. X  
  343. X+ 
  344. X  Page 11
  345. X  
  346. X  
  347. X***************
  348. X*** 731,736 ****
  349. X--- 731,738 ----
  350. X  
  351. X  
  352. X  
  353. X+      If    the environment    variable ``USAGECNTL'' is empty    or unde-
  354. X+      fined, then the default usage level (which    is presently
  355. X       ``Verbose + Options'') will be used.
  356. X  
  357. X  MULTI-VALUED ARGUMENTS
  358. X***************
  359. X*** 781,791 ****
  360. X        ( StrVec.array[ StrVec.count ] == (char *)NULL )
  361. X  
  362. X       is    always true, and character-vectors will    always have an
  363. X-      extra NUL-character at the    end such that:
  364. X  
  365. X  
  366. X  
  367. X- 
  368. X  Page 12
  369. X  
  370. X  
  371. X--- 783,791 ----
  372. X***************
  373. X*** 797,802 ****
  374. X--- 797,804 ----
  375. X  
  376. X  
  377. X  
  378. X+      extra NUL-character at the    end such that:
  379. X+ 
  380. X        ( CharVec.array[ CharVec.count ] == '\0' )
  381. X  
  382. X       is    always true. Integer and floating point    vectors    contain
  383. X***************
  384. X*** 847,854 ****
  385. X              i, StrVec.array[i], StrVec.flags[i] );
  386. X  
  387. X           for ( i = 0 ; i < NumVec.count ; i++ )
  388. X-         printf(    "Number[%d]=%s,    flags=%x\n",
  389. X-             i, NumVec.array[i], NumVec.flags[i] );
  390. X  
  391. X  
  392. X  
  393. X--- 849,854 ----
  394. X***************
  395. X*** 863,868 ****
  396. X--- 863,871 ----
  397. X  
  398. X  
  399. X  
  400. X+         printf(    "Number[%d]=%s,    flags=%x\n",
  401. X+             i, NumVec.array[i], NumVec.flags[i] );
  402. X+ 
  403. X           listFree( StrList );
  404. X           StrList = ARGLISTNULL;
  405. X  
  406. X***************
  407. X*** 912,920 ****
  408. X        typedef ARGVEC_T(FILE    *)  FILEvec_t;
  409. X  
  410. X        BOOL    argReadFile(  ARGDESC *ad,  char *vp,  BOOL copyf  )
  411. X-       {
  412. X-            register    FILE *fp;
  413. X-            fp = fopen(vp, "r");
  414. X  
  415. X  
  416. X  
  417. X--- 915,920 ----
  418. X***************
  419. X*** 929,934 ****
  420. X--- 929,938 ----
  421. X  
  422. X  
  423. X  
  424. X+       {
  425. X+            register    FILE *fp;
  426. X+            fp = fopen(vp, "r");
  427. X+ 
  428. X             if ( ! fp ) {
  429. X              usrerr("cannot open    '%s' for reading", vp);
  430. X              return (FALSE);
  431. X***************
  432. X*** 978,989 ****
  433. X       ment descriptor) is always    used to    match for possible argu-
  434. X       ments (or keywords, or qualifiers).
  435. X  
  436. X-      For all supported operating systems, a long option    may be
  437. X-      matched in    one of two ways: it may    match all uppercase char-
  438. X-      acters in the prompt field, or it may match all characters
  439. X  
  440. X  
  441. X- 
  442. X  Page 15
  443. X  
  444. X  
  445. X--- 982,989 ----
  446. X***************
  447. X*** 995,1000 ****
  448. X--- 995,1003 ----
  449. X  
  450. X  
  451. X  
  452. X+      For all supported operating systems, a long option    may be
  453. X+      matched in    one of two ways: it may    match all uppercase char-
  454. X+      acters in the prompt field, or it may match all characters
  455. X       in    the prompt field (as in    ``+count=4'' and ``+rep-
  456. X       count=4'').
  457. X  
  458. X***************
  459. X*** 1045,1055 ****
  460. X        the pc_ARGFLAGS functions code) was found in the given
  461. X        argdesc-array    or in its default-list.
  462. X  
  463. X-      pe_BADMODE
  464. X-       Bad mode for given command in    parsecntl. This    occurs
  465. X  
  466. X  
  467. X- 
  468. X  Page 16
  469. X  
  470. X  
  471. X--- 1048,1055 ----
  472. X***************
  473. X*** 1061,1066 ****
  474. X--- 1061,1068 ----
  475. X  
  476. X  
  477. X  
  478. X+      pe_BADMODE
  479. X+       Bad mode for given command in    parsecntl. This    occurs
  480. X        when pc_WRITE    or pc_RDWR mode    is passed to parsecntl in
  481. X        conjunction with the pc_ARGFLAGS functions code.  Par-
  482. X        secntl will not modify existing arguments.
  483. X***************
  484. X*** 1110,1121 ****
  485. X  
  486. X        -f-dash_arg1 -f-dash_arg2  ...
  487. X  
  488. X- BUGS
  489. X-      When a non-multivalued argument appears more than once on
  490. X-      the command-line then only    the last value supplied    is used.
  491. X  
  492. X  
  493. X  
  494. X  Page 17
  495. X  
  496. X  
  497. X--- 1112,1121 ----
  498. X  
  499. X        -f-dash_arg1 -f-dash_arg2  ...
  500. X  
  501. X  
  502. X  
  503. X  
  504. X+ 
  505. X  Page 17
  506. X  
  507. X  
  508. X***************
  509. X*** 1127,1132 ****
  510. X--- 1127,1135 ----
  511. X  
  512. X  
  513. X  
  514. X+ BUGS
  515. X+      When a non-multivalued argument appears more than once on
  516. X+      the command-line then only    the last value supplied    is used.
  517. X       A problem occurs however in the following scenario: suppose
  518. X       `-s' is an    option that takes an optional string argument (nd
  519. X       suppose `-x' is some boolean flag). Then if the following
  520. X***************
  521. X*** 1156,1164 ****
  522. X       argument flags ARGPOS, ARGVALOPT, ARGVALREQ, ARGVALGIVEN,
  523. X       ARGNOVAL, and ARGVEC; and VAX/VMS version and IBM-PC version
  524. X       by    Brad Appleton
  525. X- 
  526. X- 
  527. X- 
  528. X  
  529. X  
  530. X  
  531. X--- 1159,1164 ----
  532. XNo differences encountered
  533. END_OF_FILE
  534. if test 9637 -ne `wc -c <'TXTPATCH'`; then
  535.     echo shar: \"'TXTPATCH'\" unpacked with wrong size!
  536. fi
  537. # end of 'TXTPATCH'
  538. fi
  539. echo shar: End of shell archive.
  540. exit 0
  541.  
  542. exit 0 # Just in case...
  543. -- 
  544. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  545. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  546. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  547. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  548.